<?php
include("../includes/common.php");
if($islogin2==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
include './head.php';
$uid=$rs=$DB->query("select * from pay_user WHERE name={$pid}"); 
foreach($uid as $res){
 $usid=$res['id'];
}
if($conf['ranking']==0){
      exit("<script language='javascript'>alert('本站管理员暂未开启商户排行功能，如有疑问请联系客服！');history.go(-1);</script>");
    }
$rs = $DB->query("      
    SELECT pay_user.id AS pid, pay_user.qq AS qq, 
              (SELECT SUM(money) FROM pay_order WHERE STATUS='1' AND TO_DAYS(endtime)=TO_DAYS(NOW()) AND pid = pay_user.id) AS money
              FROM pay_user
              ORDER BY money DESC 
              LIMIT 0 , 10
            ");
$i = 1;

?>

<div class="clearfix"></div>
  <div class="content-wrapper">
    <div class="container-fluid">  
     <div class="row pt-2 pb-2">
        <div class="col-sm-9">
		    <h4 class="page-title">商户排行</h4>
		    <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javaScript:void();">商户</a></li>
            <li class="breadcrumb-item"><a href="javaScript:void();">排行</a></li>
            <li class="breadcrumb-item active" aria-current="page">信息</li>
         </ol>
	   </div>
      </div>
     </div>
       <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-body">
              <h5 class="card-title">商户排行</h5>
        <div class="table-responsive">
               <table class="table">
                  <thead>
                    <tr>
                      <th scope="col">商户头像</th>
                      <th scope="col">商户ID</th>
                      <th scope="col">商户排名</th>
                      <th scope="col">商户日销</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                while($res = $rs->fetch())
            {
              if($res['money']=="")$res['money']='0.00';
              $money = ceil($money/100)*100; 
              if($money<0.01)$money = "0.00";       
if ($res[qq]==null) {
              $tx="/user/kuyun/qq.png";
                } else{
              $tx='//q2.qlogo.cn/headimg_dl?bs=qq&dst_uin='.$res['qq'].'&src_uin='.$res['qq'].'&fid='.$res['qq'].'&spec=100&url_enc=0&referer=bu_interface&term_type=PC';
              
              }
                  echo '
                  
                  <tr>
                  <th> 
                  <div><a href="#!" ><img style="width: 50px;height:50px;" class="align-self-start mr-3" alt="user avatar" src='.$tx.'></a></div>
                  </th>
                <td><span class="badge badge-primary shadow-primary m-1">'.$res['pid'].'</span></td>
                <td><span class="badge badge-pill badge-danger m-1">'.$i++.'</span></td>
                        <td><span class="badge badge-success m-1">'.$res['money'].' </span></td>
                  </tr>
                  ';
                  }
                ?>
                  </tbody>
                </table>
            </div>
            </div>
          </div>
        </div>
        
      </div>
    </div>
    </div>
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    
  </div>
   
<?php include 'foot.php';?>